<?xml version="1.0" encoding="UTF-8"?>
<!--
/// 
/// MaDAson - Toolkit for Model Driven Software Development
///
/// Copyright [2006] Marcus Lankenau
/// 
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///  
///     http://www.apache.org/licenses/LICENSE-2.0
///  
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
/// 
-->
<%@ Page Language="C#" %>
<%@ Import Namespace="Madason.MetaModel" %>
<%@ Import Namespace="Madason.MetaModel.Solution" %>


<project name="madason" default="test" basedir="." xmlns="http://nant.sf.net/release/0.85-rc3/nant.xsd">

	<!--
		set up variables/settings
	-->
	<target name="init">
		<property name="build.dir" value="build"/>
		<property name="libs.dir" value="libs"/>
		<property name="WarningLevel" value="0"/>
		<property name="Rebuild" value="true"/>
		<property name="Verbose" value="false"/>
		<property name="Debug" value="true"/>
	</target>


	<!--
		remove all created binaries
	-->
	<target name="clean" depends="init" description="clean">
		<delete>
			<fileset >
				<include name="${build.dir}/*.exe" />
				<include name="${build.dir}/*.dll" />
				<include name="${build.dir}/*.pdb" />
				<exclude name="${build.dir}/*vshost*.*"/>
			</fileset>
		</delete>
	</target>


	<!--
		compile all parts of the tool chain	
	-->
	<target name="compile" depends="init" description="compile">

<% 
foreach (Project project in solution.GetChildProjectsSorted())
{
   if (project.NeedNantCompile)
   {	   
	   %>		
		<!--
			compile meta model
		-->
		<csc target="<%= project.Target %>" output="${build.dir}/<%= project.OutputFile %>" rebuild="${Rebuild}" warninglevel="${WarningLevel}" verbose="${Verbose}" debug="${Debug}">
			<sources>
				<include name="<%= project.ProjectDirectory %>/**/*.cs" />
			</sources>
			<references>
<% foreach (string reference in project.NantReferences)
   { %>			
				<include name="<%= reference %>" />
<% } %>
			</references>
		</csc>
		
<%
	}
} 
%>		

<% 
	foreach (Project project in solution.GetChildProjectsSorted())
	{
		if (project is WebProject && project.Dependencies.Count > 0)
		{
%>
		<copy todir="<%= project.FullName %>/bin">
			<fileset basedir="${build.dir}">
<% foreach (string reference in project.NantProjectReferences)
   { %>			
				<include name="<%= reference %>" />
<% } %>
			</fileset>
		</copy>
<%
		}
	}
 %>

	</target>


	<!--
		execute tests
	-->
	<target name="test" depends="compile">

	</target>



</project>
<script runat="server">
	private SolutionProject solution;

	public SolutionProject Solution
	{
		get { return solution; }
		set { solution = value; }
	}		
</script>